<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new EditUserCtl();
	$ctl->checkAdmin();
	$ctl->checkNotReadonly();
	$ctl->proceed();
	
	$header = new Header();
	$header->render('Update User');

	$form = $ctl->getEditUserForm();
	
	$adding = $form->isAdding();
	$addingTitle = $adding ? 'Add' : 'Edit';
	$addVal = $adding ? 'yes' : '';
	
	$id = $form->getId();
	$login = $form->getLogin();
	$name = $form->getName();
	
	$admin = $form->isAdmin();
	$connect = $form->isConnect();
	$sendEmail = $form->isSendEmail();
	
	$email = $form->getEmail();
	
?>
<form method="post">
<input type="hidden" name="pagename" value="edituser" id="pgid">
<input type="hidden" name="metname" value="" id="metid">
<input type="hidden" name="adding" value="<?php echo $addVal; ?>" >
<input type="hidden" name="id" value="<?php echo $id; ?>" >

<h2><?php echo $addingTitle; ?> User</h2>
<p>Please edit the user information below, then press submit or cancel.</p>

<table cellpadding="4" cellspacing="0" class="list">
	<tr>
		<td nowrap>Login:</td>
		<td nowrap><input type="text" name="login" value="<?php echo $login; ?>"></td>
	</tr>
	<tr>
		<td nowrap>Name:</td>
		<td nowrap><input type="text" name="name" value="<?php echo $name; ?>"></td>
	</tr>
	<tr>
		<td nowrap>Admin:</td>
		<td nowrap><?php echo HtmlUtil::getCheckbox('admin', 'on', $admin, array()); ?></td>
	</tr>
	<tr>
		<td nowrap>Connect:</td>
		<td nowrap><?php echo HtmlUtil::getCheckbox('connect', 'on', $connect, array()); ?></td>
	</tr>
	<tr>
		<td nowrap>Email:</td>
		<td nowrap><input type="text" name="email" value="<?php echo $email; ?>"></td>
	</tr>
	<tr>
		<td nowrap>Send Email:</td>
		<td nowrap><?php echo HtmlUtil::getCheckbox('sendEmail', 'on', $sendEmail, array()); ?></td>
	</tr>
	<tr>
		<td nowrap>&nbsp;</td>
		<td nowrap>
			<input type="button" value="Submit" onclick="triggerform('submit')" class="enter">
			<input type="button" value="Cancel" onclick="triggerform('cancel')" class="escape">
		</td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
